from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, Float, String, Boolean, DateTime, ForeignKey, UniqueConstraint, Index
from sqlalchemy.orm import sessionmaker, relationship
# from sqlalchemy import create_engine

# engine = create_engine("mysql+pymysql://root:Mysql-123456@192.168.33.82:3306/data", max_overflow=5)
# engine = create_engine("mysql+pymysql://root:Mysql-123456@172.26.144.196:3306/config", max_overflow=5)
Base_data = declarative_base()


# 创建单表
class TikTokVideo(Base_data):
    __tablename__ = 'TikTokVideo'
    id = Column(Integer, primary_key=True)
    createTime = Column(DateTime, nullable=False)
    desc = Column(String(256), nullable=False)
    isAd = Column(Boolean, nullable=False)
    vid = Column(String(64), nullable=False)
    commentCount = Column(Integer, nullable=False)
    diggCount = Column(Integer, nullable=False)
    playCount = Column(Integer, nullable=False)
    shareCount = Column(Integer, nullable=False)
    downloadAddr = Column(String(256), nullable=False)
    playAddr = Column(String(256), nullable=False)
    ratio = Column(String(32), nullable=False)
    filePath = Column(String(256), nullable=False)
    add_time = Column(DateTime, nullable=False)


# #定义初始化数据库函数
# def init_db():
#     Base_config.metadata.create_all(engine)
#
# #顶固删除数据库函数
# def drop_db():
#     Base_config.metadata.drop_all(engine)


